package com.asset.salesforce.view;

import java.awt.Color;

import com.asset.salesforce.domain.Invoice;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;

public class TotalTable {
	
	public static Font normalFont = new Font(FontFactory.getFont(String.valueOf(Font.TIMES_ROMAN),BaseFont.TIMES_ROMAN,9,Font.NORMAL));
	
	public PdfPTable pdfPTable(Invoice invoice)throws Exception{
				
		PdfPTable table2 = new PdfPTable(2);
		  PdfPCell cell2 = new PdfPCell (new Paragraph ("Total",new Font(FontFactory.getFont(String.valueOf(Font.TIMES_ROMAN),BaseFont.TIMES_ROMAN,11,Font.BOLD))));
		  cell2.setColspan (2);
	      cell2.setHorizontalAlignment (Element.ALIGN_CENTER);
	      cell2.setBackgroundColor (new Color (128, 200, 128));
	      //cell.setPadding (9.0f);
	      cell2.setFixedHeight(18);
	      //cell.setBorderWidth(20);
	      table2.addCell (cell2);
	      
	      if(invoice.getId()!=null){
	      cell2 = new PdfPCell(new Paragraph("Total",normalFont));
	      cell2.setHorizontalAlignment (Element.ALIGN_CENTER);
	      cell2.setBackgroundColor (new Color (255, 200, 0));
	      //cell.setPadding (9.0f);
	      cell2.setFixedHeight(18);
	      table2.addCell (cell2);
	      
	      cell2 = new PdfPCell(new Paragraph(invoice.getTotalPrice(),normalFont));
	      cell2.setHorizontalAlignment (Element.ALIGN_CENTER);
	      //cell2.setBackgroundColor (new Color (255, 200, 0));
	      //cell.setPadding (9.0f);
	      cell2.setFixedHeight(18);
	      table2.addCell (cell2);
	      
	      cell2 = new PdfPCell(new Paragraph("Discount",normalFont));
	      cell2.setHorizontalAlignment (Element.ALIGN_CENTER);
	      cell2.setBackgroundColor (new Color (255, 200, 0));
	      //cell.setPadding (9.0f);
	      cell2.setFixedHeight(18);
	      table2.addCell (cell2);
	      
	      cell2 = new PdfPCell(new Paragraph(invoice.getDiscount(),normalFont));
	      cell2.setHorizontalAlignment (Element.ALIGN_CENTER);
	     // cell2.setBackgroundColor (new Color (255, 200, 0));
	      //cell.setPadding (9.0f);
	      cell2.setFixedHeight(18);
	      table2.addCell (cell2);
	      
	      cell2 = new PdfPCell(new Paragraph("Balance",normalFont));
	      cell2.setHorizontalAlignment (Element.ALIGN_CENTER);
	      cell2.setBackgroundColor (new Color (255, 200, 0));
	      //cell.setPadding (9.0f);
	      cell2.setFixedHeight(18);
	      table2.addCell (cell2);
	      
	      cell2 = new PdfPCell(new Paragraph(invoice.getTotalPrice(),normalFont));
	      cell2.setHorizontalAlignment (Element.ALIGN_CENTER);
	      //cell2.setBackgroundColor (new Color (255, 200, 0));
	      //cell.setPadding (9.0f);
	      cell2.setFixedHeight(18);
	      table2.addCell (cell2);
	      table2.setWidthPercentage(30);
	      table2.setHorizontalAlignment(Element.ALIGN_RIGHT);
	      }
		return table2;
	}
}
